<div class="body_resize">

  <h2><%= t :header, :scope => 'grids_list' %> <br /> </h2>

  <table cellspacing="0" cellpadding="0" id="box-table-a">
    <thead>
      <tr>
        <th><%=  t :name, :scope => %w{grids_list table columns} %></th>
        <th><%=  t :rows, :scope => %w{grids_list table columns} %></th>
        <th><%=  t :columns, :scope => %w{grids_list table columns} %></th>
        <th></th>
        <th></th>
      </tr>
    </thead>
    <tbody>
      <% @grids.each do |grid| %>
        <tr>
          <td><%= h grid.name %></td>
          <td><%= h grid.rows %></td>
          <td><%= h grid.columns %></td>
          <td><%= link_to t(current_user.account_type == 'operator' ? :edit : :view, :scope => %w{grids_list table rows}), :action => 'edit', :id => grid.id %></td>
          <td>
            <% if current_user.account_type == 'operator' %>
              <%= link_to_function t(:delete, :scope => %w{grids_list table rows}), "confirmDelete('#{url_for(:action => 'destroy', :id => grid.id)}')" %>
            <% end %>
          </td>
        </tr>
      <% end %>

    </tbody>

  </table>

</div>

<script type="text/javascript">
  var url;
  function handleDelete() {
    var f = document.createElement('form');
    f.style.display = 'none';
    document.body.appendChild(f);
    f.method = 'POST';
    f.action = url;
    var m = document.createElement('input');
    m.setAttribute('type', 'hidden');
    m.setAttribute('name', '_method');
    m.setAttribute('value', 'delete');
    f.appendChild(m);
    f.submit();
  }

  function confirmDelete(url_p) {
    url = url_p;
    confirm('<%= t('grids_list.confirm_delete') %>', handleDelete);
  }
</script>